<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="box">
    {{text}}

    <hr>
    <input type="text" v-model="res">
    {{res}}
  </div>

  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
  <script>


    new Vue({
      el: '#box',
      data: {
        text: 'hello Vue',
        str: '芜湖'
      },
      computed: {
        //计算属性的完整写法
        res: {
          get () {
            //get 返回str值,如果str值有改变,则重复调用
            return this.str
          }
          ,
          set (value) {
            //value拿到的是表单的最新数据,把结果赋值给str
            this.str = value
          }

        }
      }
    })



  </script>

</body>

</html>